package com.service.base.generator.app.service.impl;

import com.service.base.generator.app.dao.DbTableInfoDao;
import com.service.base.generator.app.model.DbConfig;
import com.service.base.generator.app.model.TableInfo;
import com.service.base.generator.app.service.DbTableInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 数据库中表的元数据相关处理服务
 *
 * @author wangyongkun
 * @create 2020/12/13
 */
@Repository
@Slf4j
public class DbTableInfoServiceImpl implements DbTableInfoService {

    @Autowired
    private DbTableInfoDao dbTableInfoDao;

    @Override
    public List<TableInfo> getAllTables(DbConfig dbConfig) {
        return dbTableInfoDao.getAllTables(dbConfig);
    }

    @Override
    public void saveTableComment(TableInfo tableInfo, DbConfig dbConfig) {
        dbTableInfoDao.saveTableComment(tableInfo, dbConfig);
    }

    @Override
    public TableInfo getAllColumns(String tableName, DbConfig dbConfig) {
        return dbTableInfoDao.getAllColumns(tableName, dbConfig);
    }

    @Override
    public String testConnection(DbConfig dbConfig) {
        return dbTableInfoDao.testConnection(dbConfig);
    }
}
